﻿using NetBrick.Client;
using UniBrickCommon.Packets;
using UnityEngine;

namespace Handler
{
    public class AuthenticateResponseHandler : PacketHandler
    {
        public AuthenticateResponseHandler(Client client)
            : base(client)
        {
        }

        public override void Process(object packetData)
        {
            var authenticateResponse = (AuthenticatePacket.Response)packetData;
            Connection.GameClient.Username = authenticateResponse.Username;
            if (authenticateResponse.Success)
            {
                Application.LoadLevel(authenticateResponse.Message);
                Connection.Instance.GameStarted = true;
            }
        }
    }
}